﻿using System;

public class PlayerInputMgr : IInputMgr {

	readonly PlayerInput _playerInput;

	public float XInput { get; set; }
	public bool Jump { get; set; }
	public bool DownInput { get; set; }

	public PlayerInputMgr() {
		_playerInput = new PlayerInput();
		_playerInput.Enable();
		InitCallBack();
	}

	public void InitCallBack() {
		//XDir
		_playerInput.PlayerCtrl.XDir.performed += ctx => XInput = ctx.ReadValue<float>();
		_playerInput.PlayerCtrl.XDir.canceled += ctx => XInput = 0;

		//Jump
		_playerInput.PlayerCtrl.YUpDir.started += ctx => Jump = true;
		_playerInput.PlayerCtrl.YUpDir.performed += ctx => Jump = false;
		_playerInput.PlayerCtrl.YUpDir.canceled += ctx => Jump = false;

		//Crouch
		_playerInput.PlayerCtrl.YDownDir.performed += ctx => DownInput = true;
		_playerInput.PlayerCtrl.YDownDir.canceled += ctx => DownInput = false;
	}
}